﻿package com.badibadi.fragment;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.json.JSONException;

import com.badibadi.activity.AboutConsultingFeesActivity;
import com.badibadi.activity.ActivityOverViewActivity;
import com.badibadi.activity.AfterLandingActivity;
import com.badibadi.activity.BeforeLandingPageActivity;
import com.badibadi.activity.CalendarActivity;
import com.badibadi.activity.CalendarNearActivity;
import com.badibadi.activity.ClubApplicationFormActivity;
import com.badibadi.activity.ClubListActivity;
import com.badibadi.activity.ClubNearActivity;
import com.badibadi.activity.ConsultingEvaluationActivity;
import com.badibadi.activity.LoginActivity;
import com.badibadi.activity.ManageClubActivity;
import com.badibadi.activity.MyDataActivity;
import com.badibadi.activity.MyOtherSpaceActivity;
import com.badibadi.activity.PeopleNearByActivity;
import com.badibadi.activity.PinyinSeeOtherPeopleFriendActivity;
import com.badibadi.activity.RechargeActivity;
import com.badibadi.activity.RecordAdayToRememberActivity;
import com.badibadi.activity.RecordMyRecordListActivity;
import com.badibadi.activity.SeeOtherPeopleSpaceActivity;
import com.badibadi.adapter.AfterLandingRightSlidingFirstAdapter;
import com.badibadi.infos.MyDataInfos;
import com.badibadi.infos.Results;
import com.badibadi.infos.UserInfoModel;
import com.badibadi.mytools.Constants;
import com.badibadi.mytools.Dialog;
import com.badibadi.mytools.DisplayUtil;
import com.badibadi.mytools.IOUtils;
import com.badibadi.mytools.JSONUtils;
import com.badibadi.mytools.MySharePreferences;
import com.badibadi.mytools.MyThreadTool;
import com.badibadi.mytools.UserDataSet;
import com.badibadi.mytools.Utils;
import com.badibadi.mytools.WidgetUtils;
import com.badibadi.uniclubber.R;
import com.libjph.util.StringUtil;
//import com.lidroid.xutils.util.LogUtils;
import com.wyy.twodimcode.FinishListener;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;

/**
 * 登录后右滑（开始主要界面）LoadingPopWindows
 * 
 * @author Administrator static Collect
 */
public class AfterLandingRightSlidingFragment extends BaseFragment {
	private int minMoneyNumber = 10;
	PopupWindow mpWindow;// 设定质询费的
	public final int SCREENW = 0;
	public final int SCREENH = 1;
	private static float ScreenW, ScreenH;// 保存屏幕宽高，方便频繁调用；
	private UserInfoModel userInfoModel, XiuGaiUserInfoModel;
	private String nickName;// 昵称
	private String head;
	private MyDataInfos myDataInfos = new MyDataInfos();
	private ListView mAfter_left_ListView;
	private AfterLandingRightSlidingFirstAdapter afterLandingAdapter;
	private Bundle bun;
	static AfterLandingRightSlidingFragment afterLandingRightSlidingFragment;
	private Intent intent = null;
	private String uid;
	private boolean isFirstLogin = false;
	private String Money = "";
	private UserDataSet userDataSet;
	boolean isRun = true;// 5s刷新一次
	String lang;
	private int money_main;
	private Handler mHandler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			try {
				switch (msg.what) {
				case 1:
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_net_error));
					} catch (Exception e) {
						// TODO: handle exception
					}

					break;
				case 2:
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.wx_dengchu_success));
						Utils.ExitPrgress(getActivity());
						Intent intent = new Intent(getActivity(),
								BeforeLandingPageActivity.class);
						MySharePreferences id = new MySharePreferences(
								getActivity(), "user");// 获取用户id
						id.Clear();
						startActivity(intent);
						Constants.Dengchu_handler.sendEmptyMessage(3);
					} catch (Exception e) {
						// TODO: handle exception
					}

					break;
				case 3:
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.wx_dengchu_false));
					} catch (Exception e) {
						// TODO: handle exception
					}
					break;
				case 4:// 信息显示
					try {
						if (isFirstLogin = true) {

							afterLandingAdapter = new AfterLandingRightSlidingFirstAdapter(
									getActivity(), userInfoModel);
							mAfter_left_ListView
									.setAdapter(afterLandingAdapter);
							IOUtils.WriteSerializedObjectsToSDcard(IOUtils
									.getObjectYouHuaCaiDanPath(getActivity()),
									(Object) userInfoModel);

						} else {
							afterLandingAdapter.notifyDataSetChanged();
							IOUtils.WriteSerializedObjectsToSDcard(IOUtils
									.getObjectYouHuaCaiDanPath(getActivity()),
									(Object) userInfoModel);
						}

					} catch (Exception e) {
						// TODO: handle exception
					}

					break;
				case 5:
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_xb12));
					} catch (Exception e) {
						// TODO: handle exception
					}

					break;
				case 6:
					Utils.ExitPrgress(getActivity());
					try {

						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_xb53));
						init();
					} catch (Exception e) {
						// TODO: handle exception
					}

					break;
				case 7:
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.wx_xiugai_false));
					} catch (Exception e) {
						// TODO: handle exception
					}

					break;
				case 8:// 第八个
					Utils.ExitPrgress(getActivity());
					try {
						// Utils.showMessage(getActivity(), "");

						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.l_xb53));
						((AfterLandingActivity) (getActivity()))
								.settingRightslidingMenu();
					} catch (Exception e) {
						// TODO: handle exception
					}

					break;
				case 9:// 第八个0
					Utils.ExitPrgress(getActivity());
					try {
						Utils.showMessage(getActivity(), getResources()
								.getString(R.string.wx_xiugai_false));
						// userInfoModel.setAdvisory_fees(XiuGaiUserInfoModel.getAdvisory_fees());
						// afterLandingAdapter.notifyDataSetChanged();
					} catch (Exception e) {
						// TODO: handle exception
					}

					break;
				case 10:// 刷新

					try {
						Utils.ExitPrgress(getActivity());
						((AfterLandingActivity) getActivity())
								.settingRightslidingMenu();
					} catch (Exception e) {
						// TODO: handle exception
					}

					break;
				}
			} catch (Exception e) {
				// TODO: handle exception
				   
			}

		};
	};

	public AfterLandingRightSlidingFragment() {
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		uid = Utils.getUid(getActivity());
		// nickName=getArguments().getString("nickName", "");
		// head=getArguments().getString("head", "");

		// uid=getArguments().getString("uid");
		// nickName=getArguments().getString("nickName", "");
		// head=getArguments().getString("head", "");

	}

	public void Resh() {
		Thread t = new Thread(new RefreshDataThread());
		t.start();
	}

	// public static AfterLandingRightSlidingFragment getInstance() {
	// if (afterLandingRightSlidingFragment == null) {
	// return new AfterLandingRightSlidingFragment();
	// }
	// return afterLandingRightSlidingFragment;
	// }

	/**
	 * 
	 * 登录用户信息
	 * 
	 * @author Administrator
	 * 
	 */
	public class RefreshDataThread implements Runnable {
		@Override
		public void run() {
			// TODO Auto-generated method stub

			Map<String, Object> map = new HashMap<String, Object>();
			map.put("id", uid);
			map.put("languageType", lang);
			String content = Utils.sendRequest(map, Constants.BadiUrl
					+ "userDataShow");
			if (content != null) {
				//    ("结果是:" + content);
				Results results = Utils.checkResult_NNN(getActivity(), content);
				if (results != null && results.getRetmsg() != null) {
					//    
					//    ("得到的结果是：" + results.getRetmsg());
					try {
						userInfoModel = JSONUtils.getEntityByJsonString(
								results.getRetmsg(), UserInfoModel.class);
						userInfoModel.setUid(uid);
						mHandler.sendEmptyMessage(4);
					} catch (JSONException e) {
						//    ("解析出错");
						   
					} catch (Exception e) {
						// TODO Auto-generated catch block
						//    
						   
					}
				} else {

				}
			} else {
				mHandler.sendEmptyMessage(1);
			}
		}
	}

	// /**
	// * 一、这里是从网络上下载数据
	// *
	// * @author Administrator
	// *
	// */
	// public class RefreshDataThread implements Runnable {
	// @Override
	// public void run() {
	// // TODO Auto-generated method stub
	//
	// Map<String, Object> map = new HashMap<String, Object>();
	// map.put("id", uid);
	// map.put("languageType", com.badibadi.mytools.Dialog
	// .getSystemLanguageType(getActivity()));
	// String content = Utils.sendRequest(map, Constants.BadiUrl
	// + "userDataShow");
	// if (content != null) {
	// //    ("结果是:" + content);
	// Results results = Utils.checkResult_NNN(
	// getActivity(), content);
	// if (results != null && results.getRetmsg() != null) {
	// //    
	//    ("得到的结果是：" + results.getRetmsg());
	// try {
	// userInfoModel = JSONUtils.getEntityByJsonString(
	// results.getRetmsg(), UserInfoModel.class);
	// userInfoModel.setUid(uid);
	// mHandler.sendEmptyMessage(6);
	//
	// } catch (JSONException e) {
	//    ("解析出错");
	//    
	// } catch (Exception e) {
	// // TODO Auto-generated catch block
	//    
	//    
	// }
	// } else {
	//
	// }
	// } else {
	// Utils.ExitPrgress(MyDataActivity.this);
	// mHandler.sendEmptyMessage(2);
	// }
	// }
	// }

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		lang = com.badibadi.mytools.Dialog.getSystemLanguageType(getActivity());
		View view = init();
		// resh();
		// LogUtils.d("1="+com.badibadi.mytools.Dialog.getSystemLanguageType(getActivity())+"2="+com.badibadi.mytools.Dialog.getSystemLanguageTypegrzx(getActivity())+"3="+com.badibadi.mytools.Dialog.getSystemLanguageTypegy(getActivity()));
		// resh();
		return view;
	}

	@Override
	public void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		isRun = true;
	}

	public void resh() {
		new Thread(new Runnable() {
			@Override
			public void run() {
				// TODO Auto-generated method stub
				while (isRun) {
					try {
						Thread.sleep(10000);

						mHandler.sendEmptyMessage(10);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						   
					}
				}
			}
		}).start();
	}

	private View init() {
		// TODO Auto-generated method stub
		LayoutInflater inflater = LayoutInflater.from(getActivity());

		View view = inflater.inflate(R.layout.fragment_afterlanding_layout,
				null);
		userDataSet = new UserDataSet(getActivity());
		mAfter_left_ListView = (ListView) view
				.findViewById(R.id.after_landing_left_listView);
		// 下面的是从sdcard中获取到数据
		userInfoModel = (UserInfoModel) IOUtils
				.readSerializedObjectsToSDcard(IOUtils
						.getObjectYouHuaCaiDanPath(getActivity()));
		if (userInfoModel == null) {
			isFirstLogin = true;
			Thread t = new Thread(new RefreshDataThread());
			t.start();
		} else {
			afterLandingAdapter = new AfterLandingRightSlidingFirstAdapter(
					getActivity(), userInfoModel);
			mAfter_left_ListView.setAdapter(afterLandingAdapter);
			isFirstLogin = false;
			Thread t = new Thread(new RefreshDataThread());
			t.start();
		}
		// /////

		mAfter_left_ListView.setLayoutParams(new LinearLayout.LayoutParams(
				(int) (getScreenW() - DisplayUtil.dip2px(getActivity(), 50)),
				LinearLayout.LayoutParams.MATCH_PARENT));
		mAfter_left_ListView
				.setOnItemClickListener(new AdapterView.OnItemClickListener() {
					@Override
					public void onItemClick(AdapterView<?> arg0, View view,
							int position, long arg3) {
						// TODO Auto-generated method stub
						bun = new Bundle();
						switch (position) {
						// 附近使用者
						case 2:
							intent = new Intent(getActivity(),
									PeopleNearByActivity.class);
							break;
						// 附近的活动
						case 3:
							intent = new Intent(getActivity(),
									CalendarNearActivity.class);
							break;
						//附近的俱乐部
						case 4:
							intent = new Intent(getActivity(),
									ClubNearActivity.class);
							
							break;
						// 我的资料
						case 6:
							intent = new Intent(getActivity(),
									MyDataActivity.class);
							intent.putExtra("uid", Utils.getUid(getActivity()));
							break;
						// 历届评价
						case 7:
							intent = new Intent(getActivity(),
									ConsultingEvaluationActivity.class);
							intent.putExtra("uid", Utils.getUid(getActivity()));
							break;
						// 咨询费
						case 8:
							if (userInfoModel != null) {
								LoadingPopWindows();
							}

							// Intent intent=new
							// Intent(getActivity(),SeeOtherPeopleSpaceActivity.class);
							// intent.putExtra("friend_id", "8");
							// // startActivity(intent);

							// LinearLayout ll = new
							// LinearLayout(getActivity());
							// final EditText editText = new EditText(
							// getActivity());
							// editText.setLayoutParams(new
							// LinearLayout.LayoutParams(
							// LinearLayout.LayoutParams.MATCH_PARENT,
							// LinearLayout.LayoutParams.WRAP_CONTENT,
							// 1.0f));
							// editText.setInputType(EditorInfo.TYPE_CLASS_PHONE);
							// editText.setBackgroundResource(0);
							// TextView tv = new TextView(getActivity());
							// tv.setText("RMB");
							// ll.addView(editText);
							// ll.addView(tv);
							// new AlertDialog.Builder(getActivity())
							// .setMessage(
							// getResources()
							// .getString(
							// R.string.PleaseSetConsultingFees))
							// .setView(ll)
							// .setPositiveButton(
							// getResources().getString(
							// R.string.OK),
							// new DialogInterface.OnClickListener() {
							//
							// @Override
							// public void onClick(
							// DialogInterface dialog,
							// int which) {
							// // TODO Auto-generated
							// // method stub
							//
							// }
							// })
							// .setNegativeButton(
							// getResources().getString(
							// R.string.Return),
							// new DialogInterface.OnClickListener() {
							//
							// @Override
							// public void onClick(
							// DialogInterface dialog,
							// int which) {
							// // TODO Auto-generated
							// // method stub
							//
							// }
							// }).show();
							break;
						// 朋友
						case 9:
							// ((AfterLandingActivity) getActivity())
							// .OpenOrCloseSlidingMenu();
							// ((AfterLandingActivity) getActivity()).jiazai(6);
							try {
								Intent intent = new Intent(
										getActivity(),
										PinyinSeeOtherPeopleFriendActivity.class);
								intent.putExtra("uid", uid);
								// intent.putExtra("fid", fid);
								getActivity().startActivityForResult(intent,
										123);
							} catch (Exception e) {
								// TODO: handle exception
							}

							break;
						// 金币数量
						case 10:
							intent = new Intent(getActivity(),
									RechargeActivity.class);
							break;
						// 收藏
						case 11:
							((AfterLandingActivity) getActivity())
									.OpenOrCloseSlidingMenu();

							((AfterLandingActivity) getActivity()).enterCollect = true;
							((AfterLandingActivity) getActivity()).resh9();
							// ((AfterLandingActivity) getActivity()).jiazai(9);
							break;
						// 我的其他空间
						case 12:
							intent = new Intent(getActivity(),
									MyOtherSpaceActivity.class);
							break;
						// 管理俱乐部
						case 13:
							intent = new Intent(getActivity(),
									ManageClubActivity.class);
							break;
						// 申请表
						case 14:
							intent = new Intent(getActivity(),
									ClubApplicationFormActivity.class);
							bun.putString("showType", "user");
							break;
						// 首页
						case 16:
							((AfterLandingActivity) getActivity())
									.OpenOrCloseSlidingMenu();
							((AfterLandingActivity) getActivity()).jiazai(10);
							break;
						// 俱乐部
						case 17:
							intent = new Intent(getActivity(),
									ClubListActivity.class);
							break;
						// 活动（主题）
						case 18:
							intent = new Intent(getActivity(),
									ActivityOverViewActivity.class);
							break;
						// 每日一记
						case 19:
							intent = new Intent(getActivity(),
									RecordAdayToRememberActivity.class);
							break;
						// 购买处
						case 20:
							intent = new Intent(getActivity(),
									RechargeActivity.class);
							break;
						// 登出
						case 21:
							LoginOut();
							break;
						}
						if (intent != null) {
							getActivity().startActivity(intent);
							getActivity().overridePendingTransition(
									R.anim.slide_left, R.anim.slide_right);
							intent = null;
						}
					}
				});
		return view;
	}

	/**
	 * 参考咨询费的popwindow
	 */
	private void LoadingPopWindows() {
		final int money = 20;// 不得低于money元
		final Dialog dialog = new Dialog();
		LayoutInflater inflater = LayoutInflater.from(getActivity());
		final View root = inflater.inflate(
				R.layout.modify_consulting_fees_popwindow, null);
		if(userInfoModel!=null){
			money_main=Integer.valueOf(""+userInfoModel.getNeedGold());
		}
		(root.findViewById(R.id.Modify_Ok))
				.setOnClickListener(new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						if (userInfoModel != null) {
							if (userInfoModel.getAlipay() != null
									&& !("" + userInfoModel.getAlipay())
											.equals("")
									&& userInfoModel.getAlipayName() != null
									&& !("" + userInfoModel.getAlipayName())
											.equals("")) {
								EditText et_edit = (EditText) root
										.findViewById(R.id.et_Advisory_fees);
								if (et_edit.getText().toString().equals("")) {
									Utils.showMessage(
											getActivity(),
											getResources().getString(
													R.string.wx_txt_61));
								} else {
									Money = et_edit.getText().toString();
									if (Float.parseFloat(et_edit.getText()
											.toString().trim()) < money
											&& Float.parseFloat(et_edit
													.getText().toString()
													.trim()) != 0) {
										Utils.showMessage(
												getActivity(),
												getResources().getString(
														R.string.l_xb7)
														+ money_main
														+ getResources()
																.getString(
																		R.string.l_xb8));
									} else {
										ModifyTheZhiXunFei(et_edit.getText()
												.toString());
										// UserInfoModel user = userInfoModel;
										// userInfoModel.setAdvisory_fees(""
										// + et_edit.getText().toString());
										// userDataSet.UserDataSet2(userInfoModel,
										// 0,
										// "", false
										// );// Resh;
										// if (mpWindow != null) {
										// mpWindow.dismiss();
										// }
										dialog.DialogDissMiss();
									}
								}
							} else {
								Utils.showMessage(
										getActivity(),
										""+ getResources().getString(
														R.string.wx_txt_122));
							}

						} else {
							Utils.showMessage(
									getActivity(),
									""
											+ getResources().getString(
													R.string.l_net_error));
						}
					}
				});

		(root.findViewById(R.id.Modify_Cancle))
				.setOnClickListener(new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						// mpWindow.dismiss();
						dialog.DialogDissMiss();
					}
				});
		(root.findViewById(R.id.AboutConsultingFees))
				.setOnClickListener(new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						// TODO Auto-generated method stub
						Intent intent = new Intent(getActivity(),
								AboutConsultingFeesActivity.class);
						startActivity(intent);
						dialog.DialogDissMiss();
					}
				});
		// int h = ((int) (getScreenSize(SCREENH))) / 2;
		
		if(userInfoModel!=null){
			String text = String.format(
					getActivity().getResources().getString(
							R.string.zwckybddy10yyyczlxwdw), money_main);
			int index = text.indexOf("" + money_main);
			

			WidgetUtils.setTextTheSpecifiedLocationColor(getActivity(), text,
					(TextView) root.findViewById(R.id.tishi), getResources()
							.getColor(R.color.blue), index, minMoneyNumber);
			}else{
				String text = String.format(
						getActivity().getResources().getString(
								R.string.zwckybddy10yyyczlxwdw), money);
				int index = text.indexOf("" + money);
				

				WidgetUtils.setTextTheSpecifiedLocationColor(getActivity(), text,
						(TextView) root.findViewById(R.id.tishi), getResources()
								.getColor(R.color.blue), index, minMoneyNumber);
			}


		dialog.CreateDialog(getActivity(), root);
		// dialog.
		// mpWindow = new PopupWindow(root, (int) getScreenSize(SCREENW), h);
		// mpWindow.setWidth(LayoutParams.WRAP_CONTENT);
		// mpWindow.setHeight(LayoutParams.WRAP_CONTENT);
		// mpWindow.setBackgroundDrawable(new BitmapDrawable());
		// mpWindow.setFocusable(true);
		// mpWindow.setTouchable(true);
		// mpWindow.setOutsideTouchable(true);
		// mpWindow.showAtLocation(getActivity().findViewById(R.id.rl_show),
		// Gravity.CENTER, 0, 0);
	}

	/**
	 * @param RETURN_SCREEN
	 *            RETURN_SCREENW为返回宽 RETURN_ SCREENH 为返回高
	 * @return 返回-1为空
	 */
	public float getScreenSize(int RETURN_SCREEN) {
		DisplayMetrics metrics = new DisplayMetrics();// 获取屏幕宽高
		getActivity().getWindowManager().getDefaultDisplay()
				.getMetrics(metrics);// 1。获取窗口管理器，2默认的屏幕，3获取屏幕的大小（赋值给metrcs）

		ScreenW = metrics.widthPixels;
		ScreenH = metrics.heightPixels;
		if (RETURN_SCREEN == SCREENW)
			return ScreenW;
		else if (RETURN_SCREEN == SCREENH)
			return ScreenH;
		return -1;
	}

	protected void LoginOut() {
		// TODO Auto-generated method stub
		// try {
		// Utils.showPrgress(getActivity());
		// } catch (Exception e) {
		// // TODO: handle exception
		// }
		new Thread(new Runnable() {
			@Override
			public void run() {
				// TODO Auto-generated method stub
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("uid", uid);
				String content = Utils.sendRequest(map, Constants.BadiUrl
						+ "logout");
				//    ("登出返回数据:" + map.toString());
				if (content != null) {
					Results results = Utils.checkResult_NNN(getActivity(),
							content);
					//    
					//    ("登出返回数据:" + content + " "
					// + results.getRetmsg());
					if (results != null && results.getRetmsg() != null
							&& results.isRet()) {
						mHandler.sendEmptyMessage(2);
					} else {
						mHandler.sendEmptyMessage(3);
					}
				} else {
					mHandler.sendEmptyMessage(1);
				}
			}
		}).start();

	}

	// asdf
	/**
	 * 修改咨询费
	 * 
	 * @param zhixunfei
	 */
	public void ModifyTheZhiXunFei(final String zhixunfei) {
		MyThreadTool.fixedThreadPool.execute(new Runnable() {

			@Override
			public void run() {
				// TODO Auto-generated method stub
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("uid", uid);
				map.put("advisory_fees", zhixunfei);
				String content = Utils.sendRequest(map, Constants.BadiUrl_1
						+ "user/set_advisory_fees");
				if (content != null) {
					//    ("结果是:" + content);
					Results results = Utils.checkResult_NNN(getActivity(),
							content);
					if (results != null && results.getRetmsg() != null) {
						//    
						//    ("得到的结果是：" + results.getRetmsg());
						try {

							if (results.isRet() == true)
								mHandler.sendEmptyMessage(8);
							else
								mHandler.sendEmptyMessage(9);
						} catch (Exception e) {
							//    
							   
						}
					} else {
						mHandler.sendEmptyMessage(5);
					}
				} else {
					mHandler.sendEmptyMessage(1);
				}
			}
		});

	}

	@Override
	public void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		isRun = false;
	}

	public interface CallBack {
		public void getMessage(String msg);
	}

	private float getScreenW() {
		DisplayMetrics metrics = new DisplayMetrics();// 获取屏幕宽高
		getActivity().getWindowManager().getDefaultDisplay()
				.getMetrics(metrics);// 1。获取窗口管理器，2默认的屏幕，3获取屏幕的大小（赋值给metrcs）
		float ScreenW = metrics.widthPixels;
		return ScreenW;
	}

}
